#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N=100010;
int n,m,k,V;
int d[N],v[N],a[N];
int p[N];
int mx[N];
bool chk(int i,int j){
    int cur=v[j]*v[j]+2*a[j]*(p[i]-d[j]);
    if(cur>V*V) return 1;
    return 0;
}
void slv(){
    cin>>n>>m>>k>>V;
    for(int i=0;i<n;i++) cin>>d[i]>>v[i]>>a[i];
    for(int i=0;i<m;i++) cin>>p[i];
    for(int i=0;i<m;i++) mx[i]=-1;
    int cnt=0;
    for(int i=0;i<n;i++){
        int pos=lower_bound(p,p+m,d[i])-p;
        if(pos==m) continue;
        if(a[i]>=0){
            int l=pos,r=m-1;
            if(!chk(r,i)) continue;
            while(l<r){
                int mid=l+r>>1;
                if(chk(mid,i)) r=mid;
                else l=mid+1;
            }
            mx[m-1]=max(mx[m-1],l);
        }else{
            int l=pos,r=m-1;
            if(!chk(l,i)) continue;
            while(l<r){
                int mid=l+r+1>>1;
                if(chk(mid,i)) l=mid;
                else r=mid-1;
            }
            mx[l]=max(mx[l],pos);
        }
        cnt++;
    } 
    int cur=-1,ans=0;
    for(int i=0;i<m;i++){
        if(mx[i]<0) continue;
        if(cur>=mx[i]) continue;
        cur=i;
        ans++;
    }
    cout<<cnt<<" "<<m-ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--) slv();
    return 0;
}